/**
 * 合并字符串
 * ABC=merge('A','B','C')
 * @returns {string}
 */
function merge() {
    var returnVal = "";
    for (var i = 0; i < arguments.length; i++) {
        returnVal = returnVal.concat(arguments[i]);
    }
    return returnVal;
}

/**
 * 返回sql字符串
 * 'A'='A'.toSql()
 * @returns {string}
 */
String.prototype.toSql = function () {
    return "'" + this + "'";
}

/**
 * 返回包含%字符串
 * '%A%'='A'.toLike()
 * @returns {string}
 */
String.prototype.toLike = function () {
    return "%" + this + "%";
}

/**
 * 返回包含%字符串
 * '%A%'='A'.toLike()
 * @returns {string}
 */
String.prototype.toLikeSql = function () {
    return "'%" + this + "%'";
}

/**
 * 和nvl大同小异，nvl是对比对象，这个是对比字符串
 * @param v1
 * @param v2
 * @returns {*}
 */
function emp(v1, v2) {
    return v1 != null && v1 !== '' ? v1 : v2;
}

/**
 * 就是实现oracle的decode
 */
function decode(val) {
    if(arguments == null || arguments.length < 4) throw new Error("arguments 小于2");
    if(arguments.length % 2 !== 0) throw new Error("miss else value");
    for (var i = 1; i < arguments.length; i++) {
        var argCondition = arguments[i];
        if(arguments.length - 1 === i){
            return argCondition;
        }
        if (val === argCondition) {
            return arguments[i + 1];
        }
    }
}




